package com.ruoyi.ruoyiqywechat.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.ruoyiqywechat.domain.PrivilegeConfig;
import com.ruoyi.ruoyiqywechat.service.IPrivilegeConfigService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 权益配置Controller
 *
 * @author 好六
 * @date 2025-10-10
 */
@RestController
@RequestMapping("/privilegeConfig")
public class PrivilegeConfigController extends BaseController
{
    @Autowired
    private IPrivilegeConfigService privilegeConfigService;

    /**
     * 查询权益配置列表
     */
  //("privilegeConfig:privilegeConfig:list")
    @GetMapping("/list")
    public TableDataInfo list(PrivilegeConfig privilegeConfig)
    {
        startPage();
        List<PrivilegeConfig> list = privilegeConfigService.selectPrivilegeConfigList(privilegeConfig);
        return getDataTable(list);
    }

    /**
     * 导出权益配置列表
     */
  //("privilegeConfig:privilegeConfig:export")
    @Log(title = "权益配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PrivilegeConfig privilegeConfig)
    {
        List<PrivilegeConfig> list = privilegeConfigService.selectPrivilegeConfigList(privilegeConfig);
        ExcelUtil<PrivilegeConfig> util = new ExcelUtil<PrivilegeConfig>(PrivilegeConfig.class);
        util.exportExcel(response, list, "权益配置数据");
    }

    /**
     * 获取权益配置详细信息
     */
  //("privilegeConfig:privilegeConfig:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(privilegeConfigService.selectPrivilegeConfigById(id));
    }

    /**
     * 新增权益配置
     */
  //("privilegeConfig:privilegeConfig:add")
    @Log(title = "权益配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PrivilegeConfig privilegeConfig)
    {
        return toAjax(privilegeConfigService.insertPrivilegeConfig(privilegeConfig));
    }

    /**
     * 修改权益配置
     */
  //("privilegeConfig:privilegeConfig:edit")
    @Log(title = "权益配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PrivilegeConfig privilegeConfig)
    {
        return toAjax(privilegeConfigService.updatePrivilegeConfig(privilegeConfig));
    }

    /**
     * 删除权益配置
     */
  //("privilegeConfig:privilegeConfig:remove")
    @Log(title = "权益配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(privilegeConfigService.deletePrivilegeConfigByIds(ids));
    }
}
